package 第5章多线程编程作业.Work1.Work6;

public class Number implements Runnable{
private int k=1;
    public void run() {

        for (int i = k; i <100 ; i++) {
            if(i%2==1&&Thread.currentThread().getName()=="奇数"){
                System.out.println(Thread.currentThread().getName()+i);
                k++;
            }
            if (i%2==0&&Thread.currentThread().getName()=="偶数"){
            System.out.println(Thread.currentThread().getName()+i);
            k++;
        }
    }}

    public static void main(String[] args) {
        Number n=new Number();
        Thread t1=new Thread(n,"奇数");
        Thread t2=new Thread(n,"偶数");
        t1.start();
        t2.start();
    }
}
